#include "folderconfigureline.h"

FolderConfigureLine::FolderConfigureLine(QWidget *parent) :
    QWidget(parent)
{
    folderLabel = new QLabel("Folder to save in", this);
    folderEdit = new QLineEdit(this);
    chooseButton = new QPushButton("Choose", this);

    setLayout(new QHBoxLayout());

    layout()->addWidget(folderLabel);
    layout()->addWidget(folderEdit);
    layout()->addWidget(chooseButton);

    connect(chooseButton, SIGNAL(clicked()), this, SLOT(chooseFolder()));
}

FolderConfigureLine::~FolderConfigureLine()
{
    delete folderLabel;
    delete folderEdit;
    delete chooseButton;
}

void FolderConfigureLine::chooseFolder()
{
    QFileDialog fileDialog;
    fileDialog.setFileMode(QFileDialog::Directory);
    int result = fileDialog.exec();
    if (result == 1) {
        folderEdit->setText(fileDialog.selectedFiles()[0]);
    }
}
